#include<iostream>
#include<cmath>
using namespace std;

void del(int arr[], int &length, int i, int j) {
    if (i == j || i < 0 || j < 0 || i >= length || j >= length) {
        return ;
    }
    const int delLength = j - i + 1;
    for (int k = 0; k < delLength; k++) {
        arr[i+k] = arr[j+1+k];
    }
    length -= delLength;
    // return 1;
}

int main() {
    int arr[] = { 1, 2, 3, 4, 3, 6, 7, 8, 9 };
    int length = 9;
    del(arr, length, 3,5);
    for (int i = 0; i < length; i++) {
        cout << arr[i] << " ";
    }
    cout << endl << length;
    return 0;
}